package com.sky.controller.user;

import com.sky.dto.OrderHistoryDTO;
import com.sky.dto.OrdersPaymentDTO;
import com.sky.entity.Orders;
import com.sky.result.Result;
import com.sky.service.IOrdersService;
import com.sky.vo.OrderPaymentVO;
import com.sky.vo.OrderSubmitVO;
import com.sky.vo.OrderVO;
import com.sky.vo.UserOrdersVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @BelongsProject: sky-take-out
 * @Author: XieMingHui
 * @CreateTime: 2023-11-28  13:58
 * @Description: 用户订单API层
 * @Version: 1.0
 */
@RestController("userOrdersController")
@RequestMapping("/user/order")
public class OrdersController {
    @Resource
    private IOrdersService iOrdersService;
    /**
     * 1用户下单
     * @author: XieMingHui
     * @param: [orders]
     * @return:
     **/
    @PostMapping("/submit")
    public Result<OrderSubmitVO> addOrder(@RequestBody Orders orders){
       return iOrdersService.addOrder(orders);
    }
    /**
     * 2.用户催单
     * @author: XieMingHui
     * @param: [订单id]
     * @return: 返回成功响应
     **/
    @GetMapping("/reminder/{id}")
    public Result<String> reminder(@PathVariable Long id){
        return iOrdersService.reminder(id);
    }
    /**
     * 3.用户再来一单,获取订单id的详细信息,再次下单
     * @author: XieMingHui
     * @param: [订单id]
     * @return: 返回成功响应
     **/
    @PostMapping("/repetition/{id}")
    public Result<String> repetition(@PathVariable Long id){
        return iOrdersService.repetition(id);
    }
    /**
     * 4.历史订单查询
     * @author: XieMingHui
     * @param: [orders]
     * @return:
     **/
    @GetMapping("/historyOrders")
    public Result<UserOrdersVO> historyOrders(OrderHistoryDTO orderHistoryDTO){
        return iOrdersService.historyOrders(orderHistoryDTO);
    }
    /**
     * 5.取消订单
     * @author: XieMingHui
     * @param: [订单id]
     * @return: 操作成功
     **/
    @PutMapping("/cancel/{id}")
    public Result<String> userCancel(@PathVariable Long id){
        return iOrdersService.userCancel(id);
    }
    /**
     * 6.查询订单详情
     * @author: XieMingHui
     * @param: [orders]
     * @return:
     **/
    @GetMapping("/orderDetail/{id}")
    public Result<OrderVO> orderDetails(@PathVariable Long id){
        return iOrdersService.orderDetails(id);
    }
    /**
     * 7.订单支付
     * @author: XieMingHui
     * @param: [orders]
     * @return:
     **/
    @PutMapping("/payment")
    public Result<OrderPaymentVO> payment(@RequestBody OrdersPaymentDTO ordersPaymentDTO){
        return iOrdersService.payment(ordersPaymentDTO);
    }
}
